function sendMessageToContentScript(message, callback) {
	chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
		chrome.tabs.sendMessage(tabs[0].id, message, function(response) {
			if(callback) 
        callback(response);
		});
	});
}

function createTableButtons() {
  let param = {cmd:'content', action:'scanTables'};
  param.image = document.getElementById("selectImage").checked;
  param.link = document.getElementById("selectLink").checked;
  param.input = document.getElementById("selectInput").checked;
  param.notNull = document.getElementById("selectNotNull").checked;
  param.separator = document.getElementById("separator").value || "|";
  sendMessageToContentScript(param, function(response) {
    if ("SUCCESS" == response) {
      document.getElementById("message").innerText = "SUCCESS!"
    }
  });
}

document.getElementById("findButton").addEventListener('click', createTableButtons);
